/*
Client socket,use async select mode.
add by szz
*/

#ifndef _ASYNC_SOCKET_H_
#define _ASYNC_SOCKET_H_

#include "Common.h"
#include "SocketOps.h"
#include "../AsyncComm.h"
#include <string>
#include <queue>


class AsyncSocket :public AsyncComm
{
	const static uint32 HEART_BEAT_TIME  = 1000;
public:
	static void InitNetwork();
	// Constructor. If fd = 0, it will be assigned 
	AsyncSocket();

	virtual bool InitFD(HANDLE_FD fd, Session* pSession);
	// Destructor.
	virtual ~AsyncSocket();

	// Open a connection to another machine.
	virtual bool Connect(const char * Address);
	// Accept from the already-set fd.
	void Accept(sockaddr_in * address);
protected:
	virtual int _RawReadData(char* pBuff, uint32 nBuffLen );
	virtual int _RawWriteDate(char* pBuff, uint32 nDataLen ) ;
	virtual bool CloseFD() ;
	virtual bool _NonblockingFD() ;
	uint32 GetLastError() ;

	sockaddr_in m_address;

};

#endif
